package com.example.wechatlistview.controls;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.example.wechatlistview.R;

import java.util.List;
import java.util.Map;

public class discoverHolder extends RecyclerView.ViewHolder {
    private LinearLayout root = null;
    private ImageView headImg = null;
    private TextView name = null;

    public discoverHolder(View itemView) {
        super(itemView);
        root = (LinearLayout) itemView.findViewById(R.id.discoverBg);
        headImg = (ImageView) itemView.findViewById(R.id.discoverImg);
        name = (TextView) itemView.findViewById(R.id.discoverName);
    }

    public void bind(String[] key, List<Map<String, Object>> list, int position) {
        headImg.setImageResource((Integer) list.get(position).get(key[0]));
        name.setText((String) list.get(position).get(key[1]));
        this.itemView.setTag((String) list.get(position).get(key[2]));
    }


    public static void bind(RecyclerView.ViewHolder holder, String[] key, List<Map<String, Object>> list, int position) {
        discoverHolder mHolder = (discoverHolder) holder;

        mHolder.headImg.setImageResource((Integer) list.get(position).get(key[0]));
        mHolder.name.setText((String) list.get(position).get(key[1]));
        mHolder.root.setTag((String) list.get(position).get(key[2]));

    }
}
